<script src="/statics/front/js/lib/jquery/1.9.1/jquery.js"></script>
<form name="upload" enctype="multipart/form-data" action="<?php echo __SELF__?>" method="post" style="margin:0;padding:0;">
  <input type="file" name="img" data-type="<?php echo $_GET['type'];?>" style="position:absolute;top:0;left:0;width:100%;height:100%;padding:0;font-size:1em;cursor:pointer;" />
  <input type="hidden" name="uploadimg" value="1" />
  <input type="hidden" name="type" value="<?php echo $_REQUEST['type'];?>" />
</form>
<script>
var parentDoc = window.parent.document;
$('input[name="img"]').on('change', function() {
  var type = $(this).data('type'),
      src = $('#' + type + '_img_show', parentDoc).attr('src');
  $('#' + type + '_img_show', parentDoc).attr('src', '/statics/front/images/loading.gif');
  $('form[name="upload"]').submit();
});

<?php if($imgpath):?>
$('#<?php echo $_REQUEST['type'];?>_img_show', parentDoc).attr('src', '<?php echo $imgpath;?>');
$('#<?php echo $_REQUEST['type'];?>_img_val', parentDoc).val('<?php echo $imgpath;?>');
<?php endif;?>
</script>